#include <cstdlib>
#include <ctime>
#include <iostream>
#include "School.h"
#include "Student.h"
using namespace std;

Student::Student(void)
{
	number = artQuality = sciQuality = synQuality = 0;
	wish = 0;
	wishNum = 0;
	mySchool = 0;
}

Student::~Student(void)
{
}
int Student::calScore() {return calScore(mySchool);}

int Student::calScore( School *sch )
{
	int score = 0;

	if (sch != NULL) {
	//calculate first term
		if (this->sciQuality == 1)
			switch (sch->sciQuality) {
				case 2:
					score += 40;
					break;
				case 1:
					score += 20;
					break;
				default:
					score += 10;
			}
		if (this->artQuality == 1)
			switch (sch->artQuality) {
				case 2:
					score += 40;
					break;
				case 1:
					score += 20;
					break;
				default:
					score += 10;
			}
	}
	//calculate second term
	score += rand() % 41;
	return score;
}

int Student::calMoney() {return mySchool != 0 ? calMoney(*mySchool) : -1;}

int Student::calMoney(School sch) {
	int money = 100;
	for (int i=0; i<wishNum; ++i) {
		if (wish[i] == sch.number)
			break;
		money -= 20;
	}
	return money;
}

void Student::showMe()
{
	cout << "Student " << number+1 << " information:" << endl;
	cout << "\tsynthetical quality: " << synQuality << endl;
	cout << "\tarts quality: " << artQuality << endl;
	cout << "\tsciences quality: " << sciQuality << endl;
	cout << "wish: ";
	for (int i=0; i<wishNum; ++i)
		cout << char(wish[i]+'A') << " ";
	cout << endl;
}